package ace.module.upms.core.impl.api.impl;

import ace.cmp.core.model.R;
import ace.module.common.api.annotation.ApiLocalPriority;
import ace.module.common.core.impl.api.impl.SdkApiImpl;
import ace.module.upms.api.UpmsApplicationApi;
import ace.module.upms.api.model.dto.UpmsApplicationDto;
import ace.module.upms.core.impl.dao.entity.UpmsApplication;
import ace.module.upms.core.impl.manager.UpmsApplicationManager;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;


/**
 * 权限应用 api implements.
 *
 * @author Caspar
 *
 */
@ApiLocalPriority
@AllArgsConstructor
@Component
public class UpmsApplicationApiImpl
    extends SdkApiImpl<UpmsApplication, Long, UpmsApplicationDto, UpmsApplicationManager>
    implements UpmsApplicationApi {

  private final UpmsApplicationManager upmsApplicationManager;

  @Override
  public R<UpmsApplicationDto> getByOutTypeAndOutId(String outType, String outId) {
    UpmsApplicationDto upmsApplicationDto = upmsApplicationManager.getDtoByOutTypeAndOutId(outType, outId);
    return R.ok(upmsApplicationDto);
  }

  @Override
  public R<UpmsApplicationDto> getAndCheckByOutTypeAndOutId(String outType, String outId) {
    UpmsApplicationDto upmsApplicationDto = upmsApplicationManager.getAndCheckDtoByOutTypeAndOutId(outType, outId);
    return R.ok(upmsApplicationDto);
  }

  @Override
  public R<UpmsApplicationDto> getAdminApplication() {
    UpmsApplicationDto result = upmsApplicationManager.getDtoByAdminApplication();
    return R.ok(result);
  }

  @Override
  public R<UpmsApplicationDto> getAndCheckNotNullAdminApplication() {
    UpmsApplicationDto result = upmsApplicationManager.getDtoAndCheckNotNullByAdminApplication();
    return R.ok(result);
  }
}
